import { publicThreeClass } from "./publicDeps";

import { Color,Vector3,CurvePath,LineCurve3,QuadraticBezierCurve3,TubeGeometry,DirectionalLight,AmbientLight, PlaneGeometry,AnimationMixer, Mesh, MeshBasicMaterial } from "three";

export class pineaInit extends publicThreeClass {
  async init(): Promise<void> {
    let planeGeometry = new PlaneGeometry(10, 1000); //地面的材质，宽高

    // console.log("加载地面");
    // let planeGeometry = new PlaneGeometry(10, 1000); //地面的材质，宽高
    // let planeMaterial = new MeshBasicMaterial({ color: new Color("red") });
    // let plane = new Mesh(planeGeometry, planeMaterial); // 设置地面的位置
    // plane.position.z=1
    // plane.rotation.x = -0.48 * Math.PI; // 倾斜把竖着的垂直下来，具体参考圆周率
    // this.mixer = new AnimationMixer(plane);
    // this.deps.scene.add(plane);






    this.addControl();
  }
  initlumian(){
    const p3 = new Vector3(0, 0,0);
const p4 = new Vector3(30, 0, 0);
const p5 = new Vector3(100, 0, 0);

  }
  initGuandao(){
// 创建多段线条的顶点数据
let planeMaterial = new MeshBasicMaterial({ color: new Color("red") });
const p1 = new Vector3(0, 0,100)
const p2 = new Vector3(0, 0,30);
const p3 = new Vector3(0, 0,0);
const p4 = new Vector3(30, 0, 0);
const p5 = new Vector3(100, 0, 0);
// 1. 3D直线线段
const line1 = new LineCurve3(p1, p2);
// 2. 三维二次贝塞尔曲线
const curve = new QuadraticBezierCurve3(p2, p3, p4);
// 3. 3D直线线段
const line2 = new LineCurve3(p4, p5);

const CurvePaths = new CurvePath(); 
// 三条线拼接为一条曲线
CurvePaths.curves.push(line1, curve, line2); 

// CurvePath:路径   40：沿着轨迹细分数  2：管道半径   25：管道截面圆细分数
const geometry = new TubeGeometry(CurvePaths, 50, 2, 25);
let planes = new Mesh(geometry, planeMaterial); // 设置地面的位置

this.deps.scene.add(planes);

  }
  
  update(): void {

  }

  dispose(): void {
    this.mixer.stopAllAction();
    this.mixer = null;
    this.reset();
  }
}
